home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / 80x86 / rzr92asm.lzh / circles.asm < prev    next >
Assembly Source File  |  1992-12-31  |  12KB  |  491 lines

  1.            .286
  2.            Assume Cs:_Code, Ds:_Code
  3.  
  4. ─────────────────────────────────────────────────────────────────────────────
  5. _Stack Segment Para Stack 'Stack'
  6.     db 512 dup (?)
  7. _Stack EndS
  8. ─────────────────────────────────────────────────────────────────────────────
  9. ; The Externals
  10. ─────────────────────────────────────────────────────────────────────────────
  11.  
  12. Procedures:
  13.  
  14. EXTRN  INITIALIZE:FAR            ; Initializes the modplayer for given
  15.                                  ; sounddevice and replayrate
  16. EXTRN  LOADMODULE:FAR            ; Loads the Module into memory
  17. EXTRN  STARTPLAYING:FAR          ; Starts playing the module
  18. EXTRN  STOPPLAYING:FAR           ; Stops playing the module
  19. EXTRN  DEALLOC:FAR               ; Deallocates and erases the module
  20.                                  ; from memory
  21. EXTRN  ASKINIT:FAR
  22. Variables:
  23. EXTRN  SOUNDDEVICE:WORD          ; The Sounddevice number
  24. EXTRN  TIMERSPEED:WORD           ; The replayrate 1193182/Hertz
  25. EXTRN  SBDMA:WORD                ; SoundBlaster's DMA-Channel
  26. EXTRN  SBIRQNR:WORD              ; SoundBlaster's IRQ-Number
  27.  
  28. Special_Variables:
  29. EXTRN  BAR1,BAR2,BAR3,BAR4:WORD  ; Selfdecrementing Bars, see the docs
  30. EXTRN  SHOWPATTERNS:Word         ; Shows the patterns
  31. EXTRN  MASTERVOLUME:Word         ; Mastervolume from 0 to 64
  32.  
  33. ─────────────────────────────────────────────────────────────────────────────
  34. _Data  Segment Para Public 'Data'
  35.        Filename db 'Digital.mod',0
  36. _Data  EndS
  37.  
  38. _code      segment public
  39.  
  40. sinus      label word
  41.            include sinus.db
  42. cosinus    label word
  43.            include cosinus.db
  44. xvar       dw 0,0,0
  45. yvar       dw 0,0,0
  46. deg        dw 0,0,0
  47. degadd     dw 1,1,1 ;2,3,5
  48. dirup      dw 0,0,0
  49. dirleft    dw 0,0,0
  50. fillmin    dw 200 dup(-1)
  51. fillmax    dw 200 dup(-1)
  52. dac        label byte
  53.            REPT 2
  54.            i = 0
  55.            REPT 64
  56.            db 0,0,i
  57.            i = i + 1
  58.            ENDM
  59.            i = 63
  60.            REPT 64
  61.            db 0,0,i
  62.            i = i - 1
  63.            ENDM
  64.            ENDM
  65. dac2       label byte
  66.            i = 0
  67.            REPT 64
  68.            db 0,i,i
  69.            i = i + 1
  70.            ENDM
  71.            i = 63
  72.            REPT 64
  73.            db 63-i,63,i
  74.            i = i - 1
  75.            ENDM
  76.            i = 0
  77.            REPT 64
  78.            db 63,63-i,i
  79.            i = i + 1
  80.            ENDM
  81.            i = 63
  82.            REPT 64
  83.            db i,i,i
  84.            i = i - 1
  85.            ENDM
  86.  
  87. calcoffs   macro     ;(x,y) = (cx,ax)
  88.            mov bx,320
  89.            mul bx
  90.            add ax,cx
  91.            endm
  92.  
  93. savedac    proc      near
  94.            mov       dx,3c8h
  95.            mov       al,0
  96.            out       dx,al
  97.            mov       cx,256
  98.            mov       dx,3c9h
  99.            sti
  100.            push      ax
  101.            push      cx
  102.            push      dx
  103. check:     mov       dx,3dah
  104.            in        al,dx
  105.            test      al,8
  106.            jz        check
  107.            pop       dx
  108.            pop       cx
  109.            pop       ax
  110. step:      push      ax
  111.            push      dx
  112.            mov       dx,3dah
  113. instep:    in        al,dx
  114.            test      al,1
  115.            jz        instep
  116.            pop       dx
  117.            pop       ax
  118.            lodsb
  119.            out       dx,al
  120.            lodsb
  121.            out       dx,al
  122.            lodsb
  123.            out       dx,al
  124.            loop      step
  125.            cli
  126.            ret
  127. savedac    endp
  128.  
  129.  
  130. upgdegree  proc near
  131.            push ax
  132.            mov ax,cs:degadd[0]
  133.            add cs:deg[0],ax
  134.            cmp cs:deg[0],359
  135.            jna deg1
  136.            sub cs:deg[0],360
  137. deg1:
  138.            mov ax,cs:degadd[2]
  139.            add cs:deg[2],ax
  140.            cmp cs:deg[2],359
  141.            jna deg2
  142.            sub cs:deg[2],360
  143. deg2:
  144.            mov ax,cs:degadd[4]
  145.            add cs:deg[4],ax
  146.            cmp cs:deg[4],359
  147.            jna deg3
  148.            sub cs:deg[4],360
  149. deg3:
  150.            pop ax
  151.            ret
  152. upgdegree  endp
  153.  
  154. calcpoints proc near
  155.            mov si,cs:deg[0]
  156.            shl si,1
  157.            mov cx,cs:sinus[si]
  158.            mov ax,cs:cosinus[si]
  159.            sar cx,2
  160.            sar ax,2
  161.            add cx,160
  162.            add ax,100
  163.            mov cs:xvar[0],cx
  164.            mov cs:yvar[0],ax
  165.  
  166.            mov si,cs:deg[2]
  167.            shl si,1
  168.            mov dx,cs:sinus[si]
  169.            mov bx,cs:cosinus[si]
  170.            sar dx,3
  171.            sar bx,3
  172.            add dx,cx
  173.            add bx,ax
  174.            mov cs:xvar[2],dx
  175.            mov cs:yvar[2],bx
  176.  
  177.            mov si,cs:deg[4]
  178.            shl si,1
  179.            mov cx,cs:sinus[si]
  180.            mov ax,cs:cosinus[si]
  181.            sar cx,4
  182.            sar ax,4
  183.            add cx,dx
  184.            add ax,bx
  185.            mov cs:xvar[4],cx
  186.            mov cs:yvar[4],ax
  187.  
  188.            ret
  189. calcpoints endp
  190.  
  191. fmax       proc near
  192.            mov di,ax
  193.            shl di,1
  194.            cmp cs:fillmin[di],-1
  195.            je fillminnow
  196.            cmp cs:fillmin[di],cx
  197.            jng dontmin
  198. fillminnow:
  199.            mov cs:fillmin[di],cx
  200. dontmin:
  201.            cmp cs:fillmax[di],-1
  202.            je fillmaxnow
  203.            cmp cs:fillmax[di],cx
  204.            jg dontmax
  205. fillmaxnow:
  206.            mov cs:fillmax[di],cx
  207. dontmax:
  208.            ret
  209. fmax       endp
  210.  
  211. fillrout   proc near
  212.            mov di,0a000h
  213.            mov es,di
  214.            mov cx,200
  215. frn:
  216.            push cx
  217.            mov si,cx
  218.            dec si
  219.            shl si,1
  220.            cmp cs:fillmin[si],-1
  221.            je frskip
  222.            mov ax,cx
  223.            dec ax
  224.            mov cx,cs:fillmin[si]
  225.            CALCOFFS
  226.            mov di,ax
  227.            mov cx,cs:fillmax[si]
  228.            sub cx,cs:fillmin[si]
  229.            inc cx
  230. frnxtbt:
  231.            inc byte ptr es:[di]
  232.            inc di
  233.            loop frnxtbt
  234.            mov cs:fillmin[si],-1
  235.            mov cs:fillmax[si],-1
  236. frskip:
  237.            pop cx
  238.            loop frn
  239.            ret
  240. fillrout   endp
  241.  
  242. circle     proc near ; cx,ax = x,y   bx = radius   dl = color
  243.            mov cs:x_add,cx
  244.            mov di,0a000h
  245.            mov es,di
  246.            mov si,0
  247.            mov bp,ax
  248. cnext:
  249.            push dx
  250.            mov ax,cs:sinus[si]
  251.            mul bx
  252.            sar ax,8
  253.            mov cx,ax
  254.            add cx,cs:x_add
  255.            mov ax,cs:cosinus[si]
  256.            mul bx
  257.            sar ax,8
  258.            add ax,bp
  259.            cmp ax,0
  260.            jng notdot
  261.            cmp ax,199
  262.            jg notdot
  263.            push bx
  264.            call fmax
  265.            inc ax
  266.            call fmax
  267. ;           CALCOFFS
  268. ;           mov di,ax
  269.            pop bx
  270.            pop dx
  271. ;           mov es:[di],dl
  272.            jmp contdot
  273. notdot:
  274.            pop dx
  275. contdot:
  276.            add si,2
  277.            cmp si,720
  278.            jne cnext
  279.            ret
  280. x_add      dw 0
  281. circle     endp
  282.  
  283. block      proc near   ; cx,ax = x,y...
  284.            CALCOFFS
  285.            mov di,0a000h
  286.            mov es,di
  287.            mov di,ax
  288.            mov cx,30
  289. badd2:
  290.            push cx
  291.            mov cx,30
  292. badd:
  293.            inc byte ptr es:[di]
  294.            inc di
  295.            loop badd
  296.            pop cx
  297.            add di,290
  298.            loop badd2
  299.            ret
  300. block      endp
  301.  
  302. updbadd    proc near
  303.            mov di,0
  304. bagain:
  305.            mov ax,cs:dirleft[di]
  306.            add cs:xvar[di],ax
  307.            cmp cs:xvar[di],0
  308.            jne not1
  309.            mov cs:dirleft[di],1
  310. not1:
  311.            cmp cs:xvar[di],290
  312.            jne not2
  313.            mov cs:dirleft[di],-1
  314. not2:
  315.            mov ax,cs:dirup[di]
  316.            add cs:yvar[di],ax
  317.            cmp cs:yvar[di],0
  318.            jne not3
  319.            mov cs:dirup[di],1
  320. not3:
  321.            cmp cs:yvar[di],170
  322.            jne not4
  323.            mov cs:dirup[di],-1
  324. not4:
  325.            add di,2
  326.            cmp di,6
  327.            jne bagain
  328.            ret
  329. updbadd    endp
  330.  
  331. badder     proc near
  332.            mov cs:xvar[0],0
  333.            mov cs:xvar[2],100
  334.            mov cs:xvar[4],200
  335.            mov cs:yvar[0],100
  336.            mov cs:yvar[2],0
  337.            mov cs:yvar[4],100
  338.            mov cs:dirup[0],1
  339.            mov cs:dirup[2],1
  340.            mov cs:dirup[4],1
  341.            mov cs:dirleft[0],1
  342.            mov cs:dirleft[2],1
  343.            mov cs:dirleft[4],1
  344.  
  345.            mov cx,5000
  346. bax:
  347.            push cx
  348.            mov ah,1
  349.            int 16h
  350.            call updbadd
  351.            mov cx,cs:xvar[0]
  352.            mov ax,cs:yvar[0]
  353.            call block
  354.            mov cx,cs:xvar[2]
  355.            mov ax,cs:yvar[2]
  356.            call block
  357.            mov cx,cs:xvar[4]
  358.            mov ax,cs:yvar[4]
  359.            call block
  360.            pop cx
  361.            loop bax
  362.  
  363.            ret
  364. badder     endp
  365.  
  366. start      proc near
  367.        Mov  Ah,4Ah                ; Reduce program memory size
  368.        Mov  Bx,50000/16           ; Approx. size of compiled EXEFILE / 16 + 2
  369.        Int  21h
  370.  
  371.        Mov  Ax,_Data
  372.        Mov  Ds,Ax
  373.  
  374.        Call Askinit              ; Ask for the setup
  375.        Call Initialize           ; Initialize the SoundSystem
  376.  
  377.            mov ax,13h
  378.            int 10h
  379.  
  380.        Mov  Dx,Offset FileName
  381.        Call Loadmodule           ; Load the module
  382.  
  383.        Call StartPlaying         ; Roll it !
  384.        Mov  Al,01111010b         ; Mask off all unneccesary interrupts.
  385.        Out  21h,Al
  386.  
  387.            mov si,cs
  388.            mov ds,si
  389.            mov si,offset dac
  390.  
  391.            call savedac
  392.            mov cx,3600
  393. loop1:
  394.            push cx
  395.            mov ah,1
  396.            int 16h
  397.            call upgdegree
  398.            call calcpoints
  399.            mov cx,cs:xvar[0]
  400.            mov ax,cs:yvar[0]
  401.            mov bx,64
  402.            mov dl,15
  403.            call circle
  404.            call fillrout
  405.            mov cx,cs:xvar[2]
  406.            mov ax,cs:yvar[2]
  407.            mov bx,32
  408.            mov dl,15
  409.            call circle
  410.            call fillrout
  411.            mov cx,cs:xvar[4]
  412.            mov ax,cs:yvar[4]
  413.            mov bx,16
  414.            mov dl,15
  415.            call circle
  416.            call fillrout
  417.  
  418.            mov di,0a000h
  419.            mov es,di
  420.            mov di,10000
  421.            mov cx,22000
  422.            xor ax,ax
  423.            pop cx
  424.            loop loop1
  425.  
  426.            mov ax,13h
  427.            int 10h
  428.  
  429.            mov si,cs
  430.            mov ds,si
  431.            mov si,offset dac2
  432.            mov cs:degadd[0],1
  433.            mov cs:degadd[2],2
  434.            mov cs:degadd[4],9
  435.            call savedac
  436.            mov cx,750
  437. loop2:
  438.            push cx
  439.            mov ah,1
  440.            int 16h
  441.            call upgdegree
  442.            call calcpoints
  443.            mov cx,cs:xvar[0]
  444.            mov ax,cs:yvar[0]
  445.            mov bx,64
  446.            mov dl,15
  447.            call circle
  448.            call fillrout
  449.            mov cx,cs:xvar[2]
  450.            mov ax,cs:yvar[2]
  451.            mov bx,32
  452.            mov dl,15
  453.            call circle
  454.            call fillrout
  455.            mov cx,cs:xvar[4]
  456.            mov ax,cs:yvar[4]
  457.            mov bx,16
  458.            mov dl,15
  459.            call circle
  460.            call fillrout
  461.            mov di,0a000h
  462.            mov es,di
  463.            mov di,10000
  464.            mov cx,22000
  465.            xor ax,ax
  466.            pop cx
  467.            loop loop2
  468.  
  469.            mov ax,13h
  470.            int 10h
  471.  
  472.            mov si,cs
  473.            mov ds,si
  474.            mov si,offset dac2
  475.            call savedac
  476.            call badder
  477.  
  478.            call stopplaying
  479.            call dealloc
  480.  
  481.            mov ah,0h
  482.            out 21h,al
  483.  
  484.            mov ax,4c00h
  485.            int 21h
  486.            ret
  487. start      endp
  488.  
  489. _code      ends
  490.            end start
  491.